﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using System.Data;
using System.Text;
namespace ZLDC.Estate.Quantify
{
    public partial class lp_PersonalDDetail : System.Web.UI.Page
    {
        public string t_id = "0";//分配工作人的部门ID
        public string u_id = "0";//分配工作人的ID;
        public string name = "0";//分配工作人的ID;
        public string time = "";
        public int mainid;//主表ID 用于回复和修改数据
        DataSet ds=new DataSet();
        public string type;

        public int tablecount = 0;
        public int checkcount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region
            ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds("select * from lp_Basis");
            type = _Request.GetString("type", "");
            u_id = _Request.GetString("user_id", _Utility.GetInfoBySession().m_sUserID);
            name = _Request.GetString("name", "0");
            t_id = _Request.GetString("t_id", "0");
            time = _Request.GetString("time", txtTime.Text);
            mainid = _Request.GetInt("mainid",0);
            switch (type)
            {
                case "1":
                    btnupdate.Enabled = false;
                    break;
                case "2":
                    btnupdate.Enabled = false;
                    break;
                case "":
                    break;
            }

            
            //if (ZLDC.Project.CommonLib.PageManager.CurrentUserInfo.GetPopedom("昨日检查工作"))
            //{
                btnupdate.Enabled = true;
            //}
            #endregion
            if (!IsPostBack)
            {
                if (time == "0")
                { 
                    txtTime.Text = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); 
                }
                else
                {
                    txtTime.Text = time;
                }
                
                //txtTotal1.Value=ZLDC.Topo.BLL.Estate.lp_Basis.Exists_Set();
                //if (u_id == "0")
                //{
                //    Button1.Visible = false;
                //    ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetListBasis(u_id, "and DATEDIFF(dd, CreateTime, '" + txtTime.Text + "') =0", Repeater1, txtallnum1, A2);
                //    divuserurl.InnerHtml = ZLDC.Topo.BLL.Estate.lp_myListUrl.returnUrl(_Utility.GetInfoBySession().m_sUserID);
                //}
                //else
                //{
                    ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetListBasis(u_id, "and DATEDIFF(dd, CreateTime, '" + txtTime.Text + "') =0", Repeater1, txtallnum1, A2);
                    
                        divuserurl.InnerHtml = ZLDC.Topo.BLL.Estate.lp_myListUrl.returnUrl(u_id);
                 
               // }
                //btnex();
                //GetRemark();
            }
        }
        /// <summary>
        /// 只能检查昨日工作的按钮
        /// </summary>
        protected void btnex()
        {
            if (txtTime.Text != DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"))
            {
                btnupdate.Text = "只能检查昨日工作";
                btnupdate.Enabled = false;
            }
        }


        #region
        /// <summary>
        /// 查询最高分
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected string GetHighest(object obj)
        {
            return ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetHighest(obj, ds);
        }
        /// <summary>
        /// 查询工作意见
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected void GetRemark()
        {
             //ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetRemark(txtRemark,_Utility.GetInfoBySession().m_sDeptID,u_id,txtTime.Text,Button1);
        }
        /// <summary>
        /// 查询单位
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected string GetUnit(object Quantity,object obj)
        {
            if (Quantity.ToString() == "")
            {
                return "";
            }

            return ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetUnit(obj,ds);
        }
        #endregion
        protected void btnTime_Click(object sender, EventArgs e)
        {
            if (txtTime.Text != "")
            {
                //if (u_id == "0")
                //{
                //    ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetListBasis(_Utility.GetInfoBySession().m_sUserID, "and DATEDIFF(dd, CreateTime, '" + Convert.ToDateTime(txtTime.Text) + "') =0", Repeater1, txtallnum1, A2);
                //}
                //else
                //{
                    ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.GetListBasis(u_id, "and DATEDIFF(dd, CreateTime, '" + Convert.ToDateTime(txtTime.Text) + "') =0", Repeater1, txtallnum1, A2);
                //}
                //GetRemark();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.UpdateRemark(Page, txtRemark, u_id, txtTime.Text,mainid);
        }

        protected void btnupdate_Click(object sender, EventArgs e)
        {
            ZLDC.Topo.BLL.Estate.lp_PersonalDDetail.UpdateisConfirm(Page, u_id, time);
        }


     
        protected string Getcount(string other1)
        {
            string tr = "";
         
                if (other1 == "1")
                {
                 
                        tr = "经理分配完成";
                      
                  
                }
                if (other1 == "0")
                {
                  
                        tr = "未分配完成";
                       
                }
            return tr;
        }

        /// <summary>
        /// 如果未完成 则显示红色
        /// </summary>
        /// <param name="qutity"></param>
        /// <param name="Actual_Number"></param>
        /// <returns></returns>
        protected string GetRed(string qutity, string Actual_Number)
        {
            if (int.Parse(Actual_Number) < int.Parse(qutity))
            {
                return "  <td class='STYLE10' style=\"background-color:#F89F9F\"><span >" + Actual_Number + "</span></td><td class='STYLE10'  style=\"background-color:#F89F9F\">";
            }
            else
            {
                return "<td class='STYLE10' >" + Actual_Number + "</td><td class='STYLE10'>";
            }
        }
    }
}
